#include "RunUnitTests.h"

void Run_Signal_UnitTests_CalcPhys2Raw()
{ 
	printf("/*   Test: Run_Signal_UnitTests_CalcPhys2Raw               */\n");
	bool testResult = true;

	UInt16 rawValues[]	= {0, 50, 100, 150, 200};
	UInt16 physValues[] = {0, 25, 50, 75, 100};

	Signal sig(200, 0, 100, 0);

	UInt8 sz = sizeof(rawValues) / sizeof(UInt16);

	for(UInt8 i = 0; i < sz; i++)
	{
		UInt16 rawValOrig = rawValues[i];
		UInt16 rawValCalc = sig.phys2raw(physValues[i]);

		testResult = (rawValOrig == rawValCalc) & testResult;
	}

	CheckResult(testResult);
}

void Run_Signal_UnitTests_CalcRaw2Phys()
{
	printf("/*   Test: Run_Signal_UnitTests_CalcRaw2Phys               */\n");
	bool testResult = true;

	UInt16 rawValues[]	= {0, 12, 19, 168, 199};
	UInt16 physValues[] = {0, 6, 9, 84, 99};

	Signal sig(200, 0, 100, 0);

	UInt8 sz = sizeof(rawValues) / sizeof(UInt16);

	for(UInt8 i = 0; i < sz; i++)
	{
		UInt16 physValOrig = physValues[i];
		UInt16 physValCalc = sig.raw2phys(rawValues[i]);

		testResult = (physValOrig == physValCalc) & testResult;
	}

	CheckResult(testResult);
}

void Run_Signal_UnitTests()
{
	Run_Signal_UnitTests_CalcPhys2Raw();
	Run_Signal_UnitTests_CalcRaw2Phys();
}